<style>
#foriaAdminToolsTree
{
	width: 230px;
	float:left;
	margin-right:7px;
}

#foriaAdminToolsTreeContent ul
{
	padding-left:30px;
	margin-top:3px;
	margin-bottom:0px;
}

#foriaAdminToolsTreeContent li
{
	margin:0px;
}

#foriaAdminToolsTree a
{
	display:block;
}

#foriaAdminToolsTree a:hover
{
	background: yellow;
	display: block;
}

#foriaAdminToolsTree a.clicked
{
	background: #BEEBFF;
	border: 1px solid #99DEFD;
	display: block;
}

#foriaToolsContentArea {
	overflow: auto;
	margin:0px;

}
</style>
<script>

var __BASE_TOOLS_ROUTE__ = "<?php echo base_url("admin/tools");?>";

function foriaAutoToolsResize()
{
	var baseOffsetHeight = 78;
	var baseOffsetWidth  = 270;
	var needHeight = $(window).height() - baseOffsetHeight;
	var needWidth = $(window).width() - baseOffsetWidth;
	$('#foriaToolsContentArea').width(needWidth-2);
	$('#foriaToolsContentArea').height(needHeight);
	$('#foriaAdminToolsTreeContent').height(needHeight);
}

$(window).resize(function() {
	foriaAutoToolsResize();
});

var foriaJSTools = {
	class:'',
	selected:null
};

foriaJSTools.load = function () {
	$.ajax({
		async : false,
		type: 'GET',
		dataType: 'json',
		url: __BASE_TOOLS_ROUTE__+"/load_tools/",

		success: function (r) {
			var t = '<ul>'
			for (var n in r) {
				t += '<li><a href="'+__BASE_TOOLS_ROUTE__+'/exec_tools/'+n+'" target="_blank" onclick="return foriaJSTools.exec(this, '+"'"+r[n].class+"'"+')">'+r[n].name+'</a></li>';
				t += '<ul>';
				for (var f in r[n].subfunctions) {
					t += '<li><a href="'+__BASE_TOOLS_ROUTE__+'/exec_tools/'+n+'/'+f+'" target="_blank" onclick="return foriaJSTools.exec(this, '+"'"+n+'/'+f+"'"+')">'+r[n].subfunctions[f]+'</a></li>';
				}
				t += '</ul>';
			}
			t += '</ul>';
			$('#foriaAdminToolsTreeContent').append(t);
		}
	});
}
foriaJSTools.exec = function (o, c) {
	if (foriaJSTools.class != c) {
		if (foriaJSTools.selected!=null)
			foriaJSTools.selected.removeClass('clicked');
		$('#foriaToolsContentArea').attr('src', o.href);
		$(o).addClass('clicked');
		foriaJSTools.selected = $(o);
		foriaJSTools.class=c;
	} else {
		alert ('empty request');
	}

/*
	$.ajax({
		async : false,
		type: 'GET',
		url: o.href,
		success: function (r) {
			$('#foriaToolsContentArea').html(r);
			foriaJSTools.class=c;
		}
	});
*/
	return false;
}

$(function(){
	foriaAutoToolsResize();
	foriaJSTools.load();
});

</script>
<div id="foriaAdminToolsTree">
	<div id="foriaAdminToolsTreeContent" class="ui-widget ui-widget-content ui-corner-all"></div>
</div>

<iframe src="about:blank" id="foriaToolsContentArea" class="ui-widget ui-widget-content ui-corner-all">
Выберите справа интересующий Вас пункт
</iframe>
